package com.zzyd.common.weight.activitys;

import android.annotation.SuppressLint;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.zzyd.common.R;
import com.zzyd.common.app.AppActivity;
/**
 * @author wjunjie
 * @version 1.0
 * @E-mail wang_junjie007@163.com
 * @company ZZYD
 * @createTime 2018/7/16 10:41
 * @类注释: WebView Activity封装
 */
public class WebActivity extends AppActivity {
    private WebView mWebView;
    private CoordinatorLayout rootView;
    @Override
    protected int getContentLayoutId() {
        return R.layout.activity_web;
    }

    @Override
    protected void initWidget() {
        mWebView = findViewById(R.id.web_view);
        rootView = findViewById(R.id.root_view);
        super.initWidget();
    }

    @SuppressLint("SetJavaScriptEnabled")
    @Override
    protected void initData() {
        mWebView.getSettings().setJavaScriptEnabled(true);
        mWebView.setWebViewClient(new WebViewClient());
        mWebView.setWebChromeClient(new WebChromeClient());
        mWebView.loadUrl("http://www.baidu.com");
        super.initData();
    }



    @Override
    protected void onResume() {
        mWebView.onResume();

        super.onResume();
    }

    @Override
    protected void onPause() {
        mWebView.onResume();

        super.onPause();
    }

    @Override
    protected void onDestroy() {
        rootView.removeView(mWebView);
        mWebView.destroy();
        super.onDestroy();
    }
}
